package com.climber.android.commonres.ui.preview

import android.content.Context
import android.content.Intent
import com.climber.android.commonres.R
import com.climber.android.commonres.ui.BaseMVPActivity
import io.ganguo.library.mvp.ui.mvp.IPresenter
import io.ganguo.library.mvp.ui.mvp.di.component.AppComponent
import io.ganguo.library.mvp.util.StatusBarUtils
import kotlinx.android.synthetic.main.com_activity_media_preview.*

/**
 * Created by Mikes at 2020-04-17 15:08
 * 图片/视频预览UI
 */
class MediaPreviewActivity : BaseMVPActivity<IPresenter>(){
    companion object{
        fun openMediaPreviewIntent(context: Context, preview : ArrayList<MediaPreview>) : Intent{
            return Intent(context, MediaPreviewActivity::class.java)
                    .putParcelableArrayListExtra("mediaPreview", preview)
        }
    }

    private lateinit var mediaPreviewAdapter: MediaPreviewAdapter

    private val mediaPreviewArray : List<MediaPreview> by lazy {
        intent.getParcelableArrayListExtra<MediaPreview>("mediaPreview")
    }

    override fun setupActivityComponent(appComponent: AppComponent) {
    }

    override fun getLayoutResourceId(): Int = R.layout.com_activity_media_preview

    override fun initView() {
        StatusBarUtils.setTranslucentImage(this)

        mediaPreviewAdapter = MediaPreviewAdapter(this, supportFragmentManager, mediaPreviewArray)
        vpMediaPreview.adapter = mediaPreviewAdapter
        vpMediaPreview.offscreenPageLimit = mediaPreviewArray.count() - 1
    }

    override fun initListener() {
    }

    override fun initData() {

    }
}

